Skip to content

feat: LLM-27711 Codex /compact command#145

Open
NikolaiSviridov wants to merge 3 commits into
mainfrom
nikolaisv/main/compact
Open

feat: LLM-27711 Codex /compact command#145
NikolaiSviridov wants to merge 3 commits into
mainfrom
nikolaisv/main/compact

Conversation

@NikolaiSviridov
Copy link
Copy Markdown
Collaborator

No description provided.

@NikolaiSviridov NikolaiSviridov force-pushed the nikolaisv/main/compact branch from 0719568 to d51550a Compare May 12, 2026 14:34
Comment thread src/CodexCommands.ts
}

async tryHandle(prompt: acp.ContentBlock[], sessionState: SessionState): Promise<boolean> {
async tryHandle(prompt: acp.ContentBlock[], sessionState: SessionState): Promise<CommandHandlingResult | false> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is intention behind this return type? And why we added type type CommandHandlingResult = true | TurnCompletedNotification;?


async runCompact(params: ThreadCompactStartParams): Promise<TurnCompletedNotification> {
let resolveTurnCompleted!: (event: TurnCompletedNotification) => void;
const turnCompleted = new Promise<TurnCompletedNotification>((resolve) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why compact needs to wait for turn/end? Won't this be done automatically by common event handling?

Comment thread src/CodexAcpServer.ts
usage: this.buildPromptUsage(sessionState.lastTokenUsage),
_meta: this.buildQuotaMeta(sessionState),
};
const interruptedResponse = await this.createInterruptedResponseIfNeeded(params.sessionId, turnCompleted, sessionState);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remain if (turnCompleted.turn.status === "interrupted") here and would remove "ifNeeded" from the extracted method. This would be more explicit and even more short.

}

function createTurn(id: string, status: "inProgress" | "completed") {
function createTurn(id: string, status: TurnStatus) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid propagating app-server API in the signature. This will cause app-server specifics to be added into CodexAcpServer, and will make maintaining more complicated.

)).toBe(true);
});

mockFixture.sendServerNotification(createTurnCompletedNotification("session-id", "compact-turn-id", "interrupted"));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not AcpServer.cancel()?

)).toBe(true);
});

mockFixture.sendServerNotification(createTurnCompletedNotification("session-id", "compact-turn-id"));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we manually send turn end notification?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants